home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / diskproc / replyDiskMessage.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  3.8 KB  |  127 lines

  1. /*
  2.  *   $RCSfile: replyDiskMessage.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:56:07 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37. #include "sysdefs.h"
  38. #include "ess.h"
  39. #include "checking.h"
  40. #include "trace.h"
  41. #include "error.h"
  42. #include "list.h"
  43. #include "tid.h"
  44. #include "io.h"
  45. #include "lock.h"
  46. #include "object.h"
  47. #include "msgdefs.h"
  48. #include "disk.h"
  49. #include "sharedmem_globals.h"
  50. #include "volume.h"
  51. #include "disk_funcs.h"
  52.  
  53. #include "queues.h"
  54. #include "diskproc_globals.h"
  55. #include "diskproc_intfuncs.h"
  56. #include "diskproc_extfuncs.h"
  57.  
  58. extern int    Socket;
  59. extern struct iovec iov[];
  60.  
  61. extern QUEUEPAIR *DiskQueue;
  62.  
  63.  void
  64. replyDiskMessage (
  65.  
  66.     DISKMSG        *message
  67. )
  68. {
  69. #ifdef DISKPROC_MAKE
  70.     int            bytes;
  71.  
  72.     TRACE(TR_DISKRW, TR_LEVEL_1);
  73.  
  74.     {
  75.         int blocked;
  76.  
  77.         getMutex(&(DiskQueue->fromDisk.mutex));
  78.         enq_from(DiskQueue, ShmAddressToOffset(message));
  79.         giveMutex(&(DiskQueue->fromDisk.mutex));
  80.  
  81.         /*
  82.          * Don't normally need to signal the server- it'll check the queue.
  83.          * It never waits on a semaphore, but it does select().
  84.          * We could just check to see if we're putting this on an empty 
  85.          * queue, and if so, send our volume number to the socket (kick
  86.          * the server).
  87.          * But that's not quite good enough - we really need to know if
  88.          * the server is going to block on select before it checks
  89.          * this queue. Replies->willBlock means that it will.
  90.          * See disk/selectDisk.c
  91.          */
  92.         /* Since we never set it, this doesn't need to be a critical
  93.          * section, so no need for getMutex(Replies); giveMutex(Replies);
  94.          */
  95.         blocked = Replies->willBlock;
  96.  
  97.         /* 
  98.          * We could have blocked==FALSE and server could now decide 
  99.          * to block, and we wouldn't do the kick (below).
  100.          * That's ok because we already put the item on the q, and
  101.          * so the server would find it there.
  102.          * We could also have blocked = TRUE and server could now
  103.          * return from select, and we'd have done a superfluous kick,
  104.          * but that's ok because the server throws away the extra kick.
  105.          */
  106.         if(blocked) {
  107.  
  108.             TRPRINT(TR_DISKRW, TR_LEVEL_1,
  109.                 ("Disk %d: KICKING server", SemNum));
  110.  
  111.             if((bytes = write(Socket, &SemNum, sizeof(SemNum)))<0) {
  112.                 SM_ERROR(TYPE_FATAL, errno);
  113.             }
  114.         } else {
  115.             TRPRINT(TR_DISKRW, TR_LEVEL_1, ("Disk %d: server ISN'T BLOCKED"));
  116.         }
  117.     }
  118.  
  119. #else DISKPROC_MAKE
  120.       For use with the server process "fast" path: do nothing
  121.       This never really gets compiled... there is an empty 
  122.       function like this in serverlib/disk/.
  123.       That is the one that gets compiled w/o DISKPROC_MAKE.
  124. #endif DISKPROC_MAKE
  125. }
  126.         
  127.